const {ccclass, property} = cc._decorator;
import EventManager from "../managers/EventManager";
import AudioManager from "../managers/AudioManager";
@ccclass
export default class Panel extends cc.Component {

    // LIFE-CYCLE CALLBACKS:

    // onLoad () {}

    start () {
        console.log("start panel");
        EventManager.getInstance().addEventListener("btnmusic",this.playmusic,this);
    }
    onDestroy(): void {
        EventManager.getInstance().removeEventListener("btnmusic",this.playmusic,this);
    }
    private btnEvent(e: cc.Event,data: any): void {
        console.log("data is ",data);
        if(data) {
            switch(data) {
                case "2":
                    console.log("tap panel");
                    break;
            }
            cc.director.loadScene("game");
            EventManager.getInstance().dispatchEvent({type: "btnmusic",message: "add some code",target: this});
        }
    }
    private playmusic(): void {
        AudioManager.getInstance().playEffect("music/sound.wav");
    }
    // update (dt) {}
}
